<?php
include_once('./inc/config.php');
$msg_def_err = 'Sorry, you have reached a wrong page.<br/>Please click <a href="'.$proj_config['site_url'].'" title="Click here to login">here</a> to go back to login page.';
if(!is_logged_in()) die($msg_def_err);	

$mode = $_POST['ajxfrmstatsmode'];

switch($mode)
{
	default:
		die($msg_def_err);
 	break;
	
	case 'ofc_yr':
		/************************************************************/
		//gte data set for flash chart
		//get pie charts data
		for($i = 1; $i <=12 ; $i++){
			$month = date('M', mktime(0 , 0 , 0 , $i, 1, date('Y')) );
			$monthnos[$month] = 0;
			$montharr[] = $month;
		}
		$an_code = $_SESSION['domain_sel']['c_code'];
		$query = "SELECT DATE_FORMAT(an_created, '%b') as strmon, COUNT(an_id) as info
			FROM ".TBL_ANA_DATA."
			WHERE an_code = '".$an_code."'
			AND DATE_FORMAT(an_created, '%Y') = '".date('Y')."'		
			GROUP BY DATE_FORMAT(an_created, '%b')
			";		
		$temp = $dbobj->MySQLDB_GetData($query,'ARRAY');
		foreach($temp as $val){
			$monthnos[$val['strmon']] = (int) $val['info'];
		}
		$ofc_title = 'Statistics - At a glance '.date("Y");
		$ofc_labels_x = array_keys($monthnos);
		$ofc_values_x = array_values($monthnos);
		$ofc_range_max = max($ofc_values_x)+5;
		$ofc_range_step = ceil($ofc_range_max/10);
		$ofc_legend_x = 'Stats for the Year - '.date('Y');
		$ofc_legend_y = 'Visitors';
		$ofc_chart_code = 'ajx_yr_pg';
		require(BASEPATH . 'views/ofc_ajx_chart.php');
		/*************************************************************/
	break;
	
}
?>